package com.gome.axwl.aoc.web.controller.dataDictionary;

import com.gome.axwl.aoc.common.util.BeanJsonUtil;
import com.gome.axwl.aoc.entity.dto.dataDrictionary.DataDictionaryItemDto;
import com.gome.axwl.aoc.facade.DataDictionaryFacadeService;
import com.gome.commons.core.ResultData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description: 数据字典controller
 * @Auther: yinyuxin@gome.com.cn
 * @Date: 2018/7/16 17:07
 */
@Api(tags = "数据字典")
@RestController
@RequestMapping(value = "dictionary")
public class DataDictionaryController {

    private static final Logger LOGGER=LoggerFactory.getLogger(DataDictionaryController.class);

    @Autowired
    private DataDictionaryFacadeService dataDictionaryFacadeService;

    /**
     * 根据字典类型编码查询字典明细列表
     * @param typeCode
     * @return
     */
    @ApiOperation(value = "数据字典-根据字典类型编码查询字典明细列表",  notes = "development by yinyuxin")
    @RequestMapping(value = "queryItemListByTypeCode",method = RequestMethod.GET)
    public ResultData<List<DataDictionaryItemDto>> queryItemListByTypeCode(@RequestParam(name = "typeCode") String typeCode){
        LOGGER.info("根据字典类型编码查询字典明细列表-->queryItemListByTypeCode()-->param:typeCode=",typeCode);
        ResultData<List<DataDictionaryItemDto>> resultData = dataDictionaryFacadeService.queryItemListByTypeCode(typeCode);
        LOGGER.info("根据字典类型编码查询字典明细列表-->queryItemListByTypeCode()-->result:{}",BeanJsonUtil.obj2String(resultData));
        return resultData;
    }
}
